package cn.acyou.leo.example.service.impl;

import cn.acyou.leo.example.service.StudentService;
import cn.acyou.leo.example.vo.Student;
import cn.acyou.leo.framework.util.RandomUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @author fangyou
 * @version [1.0.0, 2021-09-03 9:10]
 */
@Slf4j
@Service
public class StudentServiceImpl implements StudentService {

    @Override
    @Cacheable(value="leo:example:demo#100", key="#id")
    public Student getById(Long id) {
        Student student = new Student(id, RandomUtil.randomUserName());
        log.info("获取用户：" + student);
        return student;
    }
}
